package cn.smile.business.core.impl;

import cn.smile.bean.dto.core.SysInfoDTO;
import cn.smile.bean.entity.core.SysInfo;
import cn.smile.business.core.ISysInfoService;
import cn.smile.commons.domain.BaseServiceImpl;
import cn.smile.repository.core.SysInfoMapper;
import cn.smile.utils.BeanCopy;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SysInfoServiceImpl extends BaseServiceImpl<SysInfoMapper, SysInfo> implements ISysInfoService {
    private static final String DEFAULT_SYS_ID = "1572864233699381251";

    @Override
    public SysInfoDTO getSysInfo() {
        log.info("[SysInfoServiceImpl].[getSysInfo] ------> 查询系统信息 Start");
        SysInfo entity = baseMapper.selectOne(new QueryWrapper<SysInfo>().lambda().eq(SysInfo::getId, DEFAULT_SYS_ID).eq(SysInfo::getDeleted, Boolean.FALSE));
        SysInfoDTO dto = BeanCopy.copyBean(entity, SysInfoDTO.class);
        log.info("[SysInfoServiceImpl].[getSysInfo] ------> 查询系统信息 End, dto = {}", JSON.toJSONString(dto));
        return dto;
    }
}
